<?php
declare (strict_types = 1);
namespace app\user\service\user;

use app\common\service\BaseService;
use think\annotation\Inject;
use think\facade\Request;
use app\user\logic\user\Order as OrderLogic;
use think\Response;

/**
 * 用户个人中心接口类
 */
class Order extends BaseService
{

    /**
     * @Inject()
     * @var OrderLogic
     */
    protected $orderLogic;
    
    public function orders(string $type): Response
    {
        $param = Request::get();
        $data = $this->orderLogic->getOrders($type, $param);

        return static::parseToData($data, 1, '获取成功');
    }

    public function getOrderInfo($order_no)
    {
        $data = $this->orderLogic->getOrderInfo($order_no);

        return static::parseToData($data, 1, '获取成功');
    }

    public function cancel(): Response
    {
        $order_no = Request::put('order_no/s');
        $data     = $this->orderLogic->cancel($order_no);

        return static::parseToData($data, 1, '取消成功');
    }

    public function softDel(): Response
    {
        $order_no = Request::delete('order_no/s');
        $this->orderLogic->softDel($order_no);

        return static::parseToData([], 1, '删除成功');
    }
}
